﻿using System;
using Framework.UILogic;
// using Framework.Base;
using UnityEngine.SceneManagement;
using Object = UnityEngine.Object;

namespace Framework.Resource
{

    public class ResourceManager : FrameworkComponent, IResourceManager
    {

        // public DownloadUI DownloadUI;
        internal IResourceHelper m_helper;
        
        // private void Start()
        // {
        //     m_helper = new YooassetResourceHelper();
        // }

        public void InitResource(InitResourceCallback callback)
        {
            m_helper.InitResource(callback);
        }

        public void UpdateResourceVersion(UpdateResourceVersionCallback versionCallback)
        {
            m_helper.UpdateResourceVersion(versionCallback);
        }

        /// <summary>
        /// 同步加载
        /// </summary>
        /// <param name="assetName"></param>
        /// <param name="callback"></param>
        /// <param name="userData"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T LoadAssetSync<T>(string assetName) where T : Object
        {
          return  m_helper.LoadAssetSync<T>(assetName);
        }

        public object LoadAssetSync(string assetName, Type assetType)
        {
            return m_helper.LoadAssetSync(assetName, assetType);
        }

        public void LoadAsset<T>(string assetName, LoadAssetCallback callback,object userData) where T : Object
        {
            m_helper.LoadAsset<T>(assetName,callback,userData);
        }

        public void LoadAsset(string assetName, Type assetType, LoadAssetCallback callback,object userData)
        {
            m_helper.LoadAsset(assetName,assetType,callback,userData);
        }

        public void UnloadAsset(string assetName, UnloadAssetCallback callback)
        {
            m_helper.UnloadAsset(assetName,callback);
        }

        public void UnloadAsset(object asset, UnloadAssetCallback callback)
        {
            m_helper.UnloadAsset(asset,callback);
        }

        public void LoadScene(string sceneName, LoadSceneCallback callback, LoadSceneMode mode=LoadSceneMode.Single, bool suspendLoad=false)
        {
            m_helper.LoadScene(sceneName,callback,mode,suspendLoad);
        }

        public void UnLoadScene(string sceneName, UnloadSceneCallback callback)
        {
            m_helper.UnLoadScene(sceneName,callback);
        }

        public void DownRemoteResource(DownloadCallback downloadCallback )
        {
            m_helper.DownRemoteResource(downloadCallback);
        }
        public void UnLoadUnusedAssets(UnLoadUnusedAssetsCallback callback)
        {
            m_helper.UnLoadUnusedAssets(callback);
        }

        public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
        {
            // throw new NotImplementedException();
        }


        public override void Shutdown()
        {
            // throw new NotImplementedException();
        }
    }

}